package com.sangeng.config;

import javax.annotation.PreDestroy;

import com.sangeng.service.ArticleService;
import com.sangeng.utils.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    @Autowired
    private RedisCache redisCache;

    @Autowired
    private ArticleService articleService;

    @PreDestroy
    public void onApplicationStop() {
        // 在这里添加需要在应用程序停止时执行的代码
        System.out.println("程序结束，更新相关redis数据");
        // 执行全局的更新工作
        // 更新viewCount数据
        articleService.updateViewCountToDataBase();
    }
}